package com.dingwen.treasure.business.controller;

import com.dingwen.treasure.base.controller.BaseViewController;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.business.model.dto.CheckDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 　自定义规则校验 </br>
 * <pre>
 *     1. @Validated 比 @Valid 完善，不需要绑定 BingResult 处理
 * </pre>
 * 　@author dingwen
 * 　@date 2022/6/27
 */
@Api(tags = "自定义注解验证可选值")
@RestController
@Slf4j
@RequestMapping("custom")
public class CustomValidateController implements BaseViewController {
    /**
     * 允许值案例
     *
     * @param checkDTO 允许值dto
     * @return {@link Result}
     */
    @ApiOperation(value = "校验案例")
    @PostMapping("check")
    public Result<CheckDto> allowableValues(@RequestBody @Validated CheckDto checkDTO) {
        return success(checkDTO);
    }
}
